/*
 * @Description: mysql链接
 * @Author: cy
 * @Date: 2024/3/20
 */
const mysql = require("mysql2");

const mysqlOptions_szzj = {
  host: "10.0.13.11", //数据库主机名
  user: "data_admin",
  password: "szzjDataWorks0606",
  database: "data_sync",
};

// url: jdbc:mysql://10.0.8.20:3306/ai_construction?useUnicode=true&useSSL=false&characterEncoding=UTF-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai
//           username: ai_construction
//           password: aB3dE9fG1hJ2kL4mN@

const mysqlOptions_szzj_prod = {
  host: "10.0.13.11", //数据库主机名
  user: "szzj-screen",
  password: "Zjsz@202403",
  database: "szzj_dashboard",
};

const mysqlOptions_szzj_test = {
  host: "10.0.8.20", //数据库主机名
  user: "szzj",
  password: "abc@123",
  database: "szzj_data",
};

const mysqlOptions = {
  host: "114.55.178.89", //主机名称
  user: "express", //
  password: "4xkCjf4HzsJKkDCz",
  database: "express",
  authPlugins: {
    mysql_native_password: () =>
      require("mysql/lib/auth/mysql_native_password"),
  },
};

let connection = mysql.createConnection(mysqlOptions);

//当插入成功
// var sqlString="insert into users values(?,?)";//注意字段个数,和表名别错
// result.affectedRows==1;//影响行数

/*
* 常见增删改查例子--可以先去navicat执行。
*   let s = `select * from indexList WHERE name="阿里巴巴"`;
  let update = `UPDATE indexList SET
        name="阿里巴巴"
      WHERE score="20"`;
  let i = `insert into indexList (name,score) value ('联想',30);`;
  let d = `DELETE from indexList WHERE score=30`;
 * */

module.exports = connection;
